$(document).ready(function() {
	
	$('#TableContainer').jtable({
	
		// Field Options
		title:					'Extras',
		paging:					false,
		sorting:				false,
		deleteConfirmation:		true,
		dialogShowEffect:		'fade',	
	    dialogHideEffect:		'fade',
	    selectOnRowClick:		false,
	    selectingCheckboxes:	false,
	    selecting:				false,
	    multiselect:			false,
	
		// Actions
		actions: {
	        createAction: 	window.ajaxUrl + '/createExtraAction',
	        listAction: 	window.ajaxUrl + '/readExtraAction',
	        updateAction: 	window.ajaxUrl + '/updateExtraAction',
	        deleteAction: 	window.ajaxUrl + '/deleteExtraAction'
		},
	
		// Show Fields
		fields: {
			id: {
				key:			true,
				edit:			false,
				create:			false,
				list:			false
			},
			name: {
				title:			'Nome',
				width:			'25%',
				type:			'text',
				edit:			true,
	            create:			true,
	            list:			true
			},
			price: {
				title:			'Preco',
				width:			'6%',
				type:			'text',
				edit:			true,
	            create:			true,
	            list:			true
			},
			active: {
				title:			'Activo',
				width:			'6%',
	            type:			'checkbox',
	            values:			{'0':'no','1':'yes'},
	            setOnTextClick:	false,
	            defaultValue:	'1',
				edit:			true
				//create:			true,
				//list:			true
			},
			included_in_offer: {
				title:			'Disponivel nas ofertas?',
				width:			'13%',
				type:			'checkbox',
				values:			{'0':'não','1':'sim'},
	            setOnTextClick:	false,
	            defaultValue:	'0'
			},
			description: {
				title:			'Descrição',
				width:			'50%',
				type:			'textarea',
				list:			true
			}
			
		}
	});
	//call readeOfferAction and load data from server into the table
	$('#TableContainer').jtable('load');
});
